<?php   
	// Interface function   
	function oh_module_cron($tokens) {
        global $oh_object_cron;
        return $oh_object_cron;        
	} 
	class oh_class_cron { 
		public $cron_source;
		function oh_class_cron() {
			$this->cron_source = oh("path.script")."/crons.txt";
		}
		function at($rule) {
			$rule_time = strtotime($rule);
			$timestamp = time();
			if (false) {			
			} else if ($this->cron_source == "database") {			
			} else {
				$hash 	= md5(oh_debug_at("at").$rule);
				$crons 	= oh("frecord")->get($this->cron_source);
				$exist	= -1;
				foreach($crons as $line=>$cron) {
					$data = explode("|",$cron);
					if ($data[0] == $hash) {
						$exist = $line;
						if (($timestamp-$data[1])>(60*60*24)) {
							oh("frecord")->delete($this->cron_source, $line);					
							oh("frecord")->prepend($this->cron_source,$hash.'|'.$rule_time.'|'.$timestamp);
							return true;
						}
					}
				}
				if ($exist < 0) {
					oh("frecord")->prepend($this->cron_source,$hash.'|'.$rule_time.'|'.$timestamp);
					return true;
				}
				return false;
			}
		}
	}
	global $oh_object_cron;
	$oh_object_cron = new oh_class_cron();
?>
